from core.support import set_cutscene, get_game
from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action

class Octopus(Room):
    
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        self.octopus_alive = True
        self.octopus_ink_taken = False
      
        # build list of actions
        self.add_action(GoDeep)
        self.add_action(RunAway)
                    
    
    # return description of room.
    def get_description(self):
        if self.octopus_alive:
            return 'Watch Out!! An Octopus is blocking your way! You are frightened by its deadly tentacles. However, fighting the Octopus may prove rewarding.'
        else:
            return 'Thank God! The Octopus is dead!'
    # return image of room
    def get_image(self):
        if self.octopus_alive:
            return 'octopus.jpg'
        else:
            return 'dead_octopus.jpg'

class OctopusHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return Octopus

# define actions for this room

class GoDeep(Action):
    def __init__(self):
        Action.__init__(self, "GoDeep")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Go Deeper"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        game = get_game()
        player = game.get_player()
        if not self.room.octopus_alive:
            if 'scuba_suit' in player.inventory:
                return 'siren'
            else:
                set_cutscene("You cannot go deeper without the scuba equipment.")
                return 'octopus'
        else:
            return 'octopus'

# set cutscene for when the Octopus does not let you go past.  
    def do_action(self,game,room,request):
        if self.room.octopus_alive:
            set_cutscene("You cannot go deeper. Kill the damn Octopus first.")
        return
                           
        
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
class RunAway(Action):
    def __init__(self):
        Action.__init__(self, "RunAway")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Run Away"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'underwater'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"